//
//  LOCop.m
//  LegalObserver
//
//  Created by Roxanne Brittain on 10/30/11.
//  Copyright (c) 2011 Digifit. All rights reserved.
//

#import "LOCop.h"

@implementation LOCop
@synthesize badgeNumber, rank, weaponArray;

-(id)init
{
    self = [super init];
    if (self) {
        weaponArray = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithBool:NO], [NSNumber numberWithBool:NO], [NSNumber numberWithBool:NO], [NSNumber numberWithBool:NO], [NSNumber numberWithBool:NO], [NSNumber numberWithBool:NO], [NSNumber numberWithBool:NO], [NSNumber numberWithBool:NO], nil];
    }
    return self;
}

-(NSString*)stringDescription
{
    NSMutableString *weaponString = [NSMutableString new];
    if ([[weaponArray objectAtIndex:0] boolValue]) [weaponString appendString:@"Body Armor, "];
    if ([[weaponArray objectAtIndex:1] boolValue]) [weaponString appendString:@"Shield, "];
    if ([[weaponArray objectAtIndex:2] boolValue]) [weaponString appendString:@"Baton, "];
    if ([[weaponArray objectAtIndex:3] boolValue]) [weaponString appendString:@"Gas Mask, "];
    if ([[weaponArray objectAtIndex:4] boolValue]) [weaponString appendString:@"Pepper Spray, "];
    if ([[weaponArray objectAtIndex:5] boolValue]) [weaponString appendString:@"Tear Gas, "];
    if ([[weaponArray objectAtIndex:6] boolValue]) [weaponString appendString:@"Taser, "];
    
    if (weaponString.length > 2) 
        [weaponString replaceCharactersInRange:NSMakeRange(weaponString.length-2, 2) withString:@""];
    
    return [NSString stringWithFormat:@"Name: %@\nBadge Number: %@\nRank: %@\nWeapons: %@\nNotes: %@\n", fullName, badgeNumber, rank, weaponString, notes];
}

- (void)encodeWithCoder:(NSCoder *)coder {
    [super encodeWithCoder:coder];
    [coder encodeObject:badgeNumber forKey:@"badgeNumber"];
    [coder encodeObject:rank forKey:@"rank"];
    [coder encodeObject:weaponArray forKey:@"weaponArray"];
}

- (id)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    badgeNumber = [coder decodeObjectForKey:@"badgeNumber"];
    rank = [coder decodeObjectForKey:@"rank"];
    weaponArray = [coder decodeObjectForKey:@"weaponArray"];
    return self;
}

@end
